import axios from "axios";


const instance = axios.create({
    baseURL: "http://127.0.0.1:3007/",
    timeout: 6000,
    headers: {
        "Content-Type": "application/x-www-form-urlencoded"
    }
})


instance.interceptors.request.use((config) => {
    const token = localStorage.getItem("token");
    config.headers = { Authorization: token, ...config.headers };
    return config
}, (error) => {
    // 对请求错误做点什么
    return Promise.reject(error)
})


instance.interceptors.response.use((response) => {

    // 对响应数据做点什么
    return response;
}, (error) => {
    // 对响应错误做点什么
    return Promise.reject(error)
})


export default instance;